#include <stdio.h>
#include <queue>
#include <vector>
using namespace std;

#define rep(i,n) for (int i=0; i<n; i++)

#define TRACE(x...) 
#define PRINT(x...) TRACE(printf(x))

int n, r1, r2;
vector<int> ladj[50010];
int last;
int pred[50010];
bool vis[50010];

queue<int> q; 

void bfs() {
	rep(i,n) vis[i]=false;

	q.push(r2);

	while (!q.empty()) {
		last = q.front();
		vis[last]=true;

		rep(i,ladj[last].size()) {
			if (vis[ladj[last][i]]) continue;
			
			q.push(ladj[last][i]);
			pred[ladj[last][i]]=last;
		}

		q.pop();
	}
}

int main() {
	scanf("%d %d %d", &n, &r1, &r2);
	r1--; r2--;

	rep(i,n) {
		if (i==r1) continue;
		scanf("%d", &last);
		last--;

		ladj[i].push_back(last);
		ladj[last].push_back(i);
	}

	TRACE(
		rep(i,n) {
			printf("%d. ", i);
			rep(j,ladj[i].size()) printf("%d ", ladj[i][j]);
			printf("\n");
		}
	)

	bfs();

	rep(i,n) {
		if (i==r2) continue;
		printf("%d", pred[i]+1);
		if (i+1<n) printf(" ");
	}	
	
	printf("\n");	

	return 0;
}
